import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class insertlist {
	private static final int NUM = 10;
	static int test_case;
	
	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc =new Scanner(System.in);
		sc=new Scanner(new FileInputStream("input1.txt"));
		for (int test_case = 1; test_case <= 1; test_case++) {
			int N = sc.nextInt();
			ArrayList<Integer> arrays = new ArrayList<Integer>();
			for (int i = 0; i < N; i++) {
				arrays.add(sc.nextInt());
			}
			int M = sc.nextInt();
			for (int i = 0; i < M; i++) {
				String ID = sc.next();
				if(ID.equals("I")){
					int index = sc.nextInt();
					int count = sc.nextInt();
					for (int j = 0; j < count; j++) {
						arrays.add(index, sc.nextInt());
						index++;
					}
				}
				if(ID.equals("D")){
					int index=sc.nextInt();
					int count=sc.nextInt();
					for (int j = 0; j < count; j++) {
						arrays.remove(index);						
						
					}
				}
			}
			
			// output
			for (int i = 0; i < NUM; i++) {
				System.out.print(arrays.get(i) + "");
			}
		}
		
	}
}
